# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=markupsafe

pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.23
pkgrel=1
pkgdesc="Implements a XML/HTML/XHTML Markup safe string for Python (mingw-w64)"
arch=('any')
license=('custom')
url="http://pypi.python.org/pypi/MarkupSafe"
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools" "${MINGW_PACKAGE_PREFIX}-python3-setuptools")
source=("http://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-${pkgver}.tar.gz")
md5sums=('f5ab3deee4c37cd6a922fb81e730da6e')
 
build() {
  cd "$srcdir"

  rm -rf python{2,3}-build
  for builddir in python{2,3}-build; do
    cp -r MarkupSafe-$pkgver $builddir
    pushd $builddir
    ${MINGW_PREFIX}/bin/${builddir%-build} setup.py build
    popd
  done
}

package_python3-markupsafe() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  pushd ${MINGW_PREFIX} > /dev/null
  local _mingw_prefix=`pwd -W`
  popd > /dev/null

  cd "$srcdir/python3-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} --root="$pkgdir" -O1

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}
 
package_python2-markupsafe() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  pushd ${MINGW_PREFIX} > /dev/null
  local _mingw_prefix=`pwd -W`
  popd > /dev/null

  cd "$srcdir/python2-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root="$pkgdir" -O1

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-markupsafe() {
  package_python2-markupsafe
}

package_mingw-w64-i686-python3-markupsafe() {
  package_python3-markupsafe
}

package_mingw-w64-x86_64-python2-markupsafe() {
  package_python2-markupsafe
}

package_mingw-w64-x86_64-python3-markupsafe() {
  package_python3-markupsafe
}
